home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Rice_CMS / gopher24 / gopcli.exec < prev    next >
Encoding:
Text File  |  1993-01-24  |  7.7 KB  |  247 lines

  1. /*
  2.  *        Name: GOPCLI EXEC
  3.  *              VM TCP/IP Network GOPHER Client
  4.  *      Author: Rick Troth, Rice University, Information Systems
  5.  *              Major thanks to Arty Ecock for the wonderful RXSOCKET.
  6.  *              Thanks to Serge Goldstein for help with many things.
  7.  *        Date: 1992-Dec-23
  8.  */
  9.  
  10. /*
  11.  *      Copyright 1992 Richard M. Troth.   This software was developed
  12.  *      with resources provided by Rice University and is intended
  13.  *      to serve Rice's user community.   Rice has benefitted greatly
  14.  *      from the free distribution of software,  therefore distribution
  15.  *      of unmodified copies of this material is not restricted.
  16.  *      You may change your own copy as needed.   Neither Rice
  17.  *      University nor any of its employees or students shall be held
  18.  *      liable for damages resulting from the use of this software.
  19.  */
  20.  
  21. /*
  22.  *       Calls:
  23.  *              RXSOCKET MODULE   -- for TCP/IP network services
  24.  *              PIPE     MODULE   -- for various I/O functions
  25.  *              GLOBALV           -- for temp and perm global vars
  26.  *              XMITMSG           -- for all message output
  27.  *              VM TCP/IP, V2 or later (through RXSOCKET)
  28.  *
  29.  *              GOPCLINI EXEC     -- to initialize many things
  30.  *              GOPCLITM REXX     -- to fetch the first item (a menu)
  31.  *              GOPCLIMB REXX     -- to display a menu (from bookmarks)
  32.  *                     both of which call other gems
  33.  *
  34.  *    perm GVs:
  35.  *        HOST  -  the host to connect to for the root menu
  36.  *        PORT  -  the port on that host for Gopher service
  37.  *        PATH  -  the path to the initial menu
  38.  *        NAME  -  the name of the initial menu
  39.  *      TELNET  -  the name of the CMS TELNET command  (user preference)
  40.  *      TN3270  -  the name of the command for 3270 telnet connections
  41.  *      VIEWER  -  the CMS command (XEDIT or BROWSE) used to view a file
  42.  *   BOOKMARK.  -  prefix for all bookmark variables,  where what
  43.  *                 follows the dot is the name of the bookmark
  44.  *
  45.  *    temp GVs:
  46.  *        TUBE  -  the virtual address of a DIALed terminal (not cons)
  47.  *      GOPHER  -  the IUCV path name and translate table name
  48.  *      PROGID  -  program name
  49.  *        ITEM  -  a line of "gopher menu data" for the chosen item
  50.  *         ...
  51.  */
  52.  
  53. Trace "OFF"
  54.  
  55. Address "COMMAND"
  56.  
  57. 'SET LANGUAGE (ADD GOP USER'
  58. If rc ^= 0 Then Exit rc
  59.  
  60. 'STATE PIPE MODULE *'
  61. If rc ^= 0 Then Do
  62.     qrc = rc
  63.     /*  "You must have CMS Pipelines to run CMS Gopher."  */
  64.     'XMITMSG 3 (APPLID GOP CALLER CLI ERRMSG'
  65.     Exit qrc
  66.     End  /*  If  ..  Do  */
  67.  
  68. /*  Thanks to Nick LaFlamme for the linemode catcher.  */
  69. 'PIPE COMMAND QUERY DISPLAY'
  70. If rc ^= 0 Then Do
  71.     qrc = rc
  72.     'XMITMSG 523 (ERRMSG'       /*  "Typewriter mode"  */
  73.     /*  "CMS Gopher requires a full-screen terminal."  */
  74.     'XMITMSG 926 (APPLID GOP CALLER CLI ERRMSG'
  75.     Exit qrc
  76.     End  /*  If  ..  Do  */
  77.  
  78. 'STATE RXSOCKET MODULE *'
  79. If rc ^= 0 Then Do
  80.     qrc = rc
  81.     /*  "You must have RXSOCKET to run CMS Gopher."  */
  82.     'XMITMSG 1 (APPLID GOP CALLER CLI ERRMSG'
  83.     Exit qrc
  84.     End  /*  If  ..  Do  */
  85.  
  86. 'STATE TCPIP DATA *'
  87. If rc ^= 0 Then Do
  88.     qrc = rc
  89.     /*  "You must have VM TCP/IP V2 to run CMS Gopher."  */
  90.     'XMITMSG 2 (APPLID GOP CALLER CLI ERRMSG'
  91.     Exit qrc
  92.     End  /*  If  ..  Do  */
  93.  
  94. Parse Arg host port path '(' options ')' .
  95.  
  96. If host = "" & options = "" Then 'GLOBALV SELECT GOPHER GET PATH NAME'
  97.                             Else name = ""
  98.  
  99. /* Initialize some variables */
  100. bookmark = ""
  101. bkl  = 0
  102. tube = "CONS"
  103. quit = 0
  104.  
  105. /* process options, if any */
  106. Do While options ^= ""
  107.     Parse Var options op options
  108.     Upper op
  109.     Select  /*  op  */
  110.         When    Abbrev("TOPIC",op,2)    | ,
  111.                 Abbrev("PATH",op,1)     Then Do
  112.                     path = options
  113.                     options = ""
  114.                     End  /*  When  ..  Do  */
  115.         When    Abbrev("TUBE",op,2)     Then
  116.                     Parse Var options tube options
  117.         When    Abbrev("BOOKMARK",op,1) | ,
  118.                 Abbrev("BKMARK",op,3)   Then
  119.                     Parse Var options bookmark options
  120.         When    Abbrev("BOOKLIST",op,5) | ,
  121.                 Abbrev("BKLIST",op,3)   Then Do
  122.                     bkl = 1
  123.                     End  /*  When  ..  Do  */
  124.         When    Abbrev("TITLE",1)       Then Do
  125.                     name = options
  126.                     options = ""
  127.                     End  /*  When  ..  Do  */
  128.         Otherwise 'XMITMSG 3 OP (ERRMSG'
  129.         End  /*  Select  op  */
  130.     End  /*  Do  While  */
  131.  
  132. /*  initialize many GlobalVs,  including screen stem  */
  133. 'EXEC GOPCLINI' tube
  134.  
  135. /*  Now go display first menu or file or bookmark  */
  136. Select
  137.     When    bkl         Then Call BOOKLIST
  138.     When bookmark ^= "" Then Call BOOKMARK
  139.     Otherwise                Call SHOWITEM
  140.     End  /*  Select  */
  141.  
  142. /*  clear some work GlobalVs  */
  143. 'GLOBALV SELECT GOPHER SET PROGID'
  144. 'GLOBALV SELECT GOPHER SET GOPHER'
  145. 'GLOBALV SELECT GOPHER SET TUBE'
  146. 'GLOBALV SELECT GOPHER SET ITEM'
  147. 'GLOBALV SELECT GOPHER SET COMMAND QUIT'        /* no recursion here */
  148.  
  149. Exit
  150.  
  151.  
  152.  
  153. /* ------------------------------------------------------------ SHOWITEM
  154.  */
  155. SHOWITEM:
  156.  
  157. If host = "" Then 'GLOBALV SELECT GOPHER GET HOST'
  158. If host = "" Then host = "gopher.tc.umn.edu"
  159.  
  160. If port = "" Then 'GLOBALV SELECT GOPHER GET PORT'
  161. If port = "" Then port = 70
  162.  
  163. If name = "" Then Do
  164.     Parse Value Reverse(path) With name '/' .
  165.     name = Reverse(name)
  166.     End  /*  If  ..  Do  */
  167.  
  168. If name = "" Then Do
  169.     'PIPE COMMAND XMITMSG 4 (APPLID GOP CALLER CLI | VAR NAME'
  170.     Parse Var name . name
  171.     End  /*  If  ..  Do  */
  172.  
  173. type = Left(path,1)
  174. If type = '/' | type = ' ' Then type = '1'
  175.  
  176. item = type || name || '05'x || path || '05'x ,
  177.             || host || '05'x || port || '05'x
  178. 'PIPE VAR ITEM | GOPCLITM OPEN | CONSOLE'
  179.  
  180. Return
  181.  
  182.  
  183.  
  184. /* ------------------------------------------------------------ BOOKMARK
  185.  *  Present the selected bookmark or fall-back to the list of all.
  186.  */
  187. BOOKMARK:
  188.  
  189. /*  if bookmark was specified numeric,  just fetch it  */
  190. If Datatype(bookmark,'N') Then Do
  191.     i = Trunc(bookmark)
  192.     'PIPE COMMAND GLOBALV SELECT GOPHER GET BOOKMARK.' || i
  193.     If bookmark.i ^= "" Then Do
  194.         'PIPE VAR BOOKMARK.' || i '| GOPCLITM OPEN | CONSOLE'
  195.         Return
  196.         End  /*  If  ..  Do  */
  197.     End  /*  If  ..  Do  */
  198.  
  199.  
  200.  
  201. /* ------------------------------------------------------------ BOOKLIST
  202.  *  Present a menu of all of the user's bookmarks.
  203.  */
  204. BOOKLIST:
  205.  
  206. If name = "" Then Do
  207.     /*  extract personal name from NAMES file  */
  208.     Parse Value Diag(08,'QUERY USERID') With user . host . '15'x .
  209.     'PIPE COMMAND NAMEFIND :USERID' user ':NODE' host ,
  210.         ':NAME | VAR PERSONAL'
  211.     If rc = 0 & personal ^= "" Then
  212.         /*  make a title line for bookmark list  */
  213.         'PIPE COMMAND XMITMSG 40 PERSONAL' ,
  214.             '(APPLID GOP CALLER CLI NOHEADER | VAR NAME'
  215.     End  /*  If  ..  Do  */
  216.  
  217. /*  extract bookmarks from GlobalVs  */
  218. 'PIPE COMMAND GLOBALV SELECT GOPHER LIST' ,
  219.         '| LOCATE 1-10 / BOOKMARK./ | SPEC /=/ 1 2-* NEXT | VARLOAD'
  220. If ^Datatype(bookmark.0,'N') Then bookmark.0 = 0
  221.                              Else bookmark.0 = Trunc(bookmark.0)
  222.  
  223. 'PIPE STEM BOOKMARK. | GOPCLIMB' name '| CONSOLE'
  224. If rc ^= 0 Then Return
  225.  
  226. 'GLOBALV SELECT GOPHER GET COMMAND'
  227. Parse Upper Var command verb .
  228. If Abbrev("QUIT",verb,1) Then Return
  229.  
  230. /*  remove any blanked (deleted) bookmarks from the stem  */
  231. j = 0
  232. 'GLOBALV SELECT GOPHER GET BOOKMARK.0'
  233. Do i = 1 to bookmark.0
  234.     'GLOBALV SELECT GOPHER GET BOOKMARK.' || i
  235.     If  Symbol("BOOKMARK." || i) = "LIT"    | ,
  236.                       bookmark.i = ""       | ,
  237.                  Left(bookmark.i,1) = 'i'   Then    Iterate
  238.     j = j + 1
  239.     bookmark.j = bookmark.i
  240.     'GLOBALV SELECT GOPHER PUTP BOOKMARK.' || j
  241.     End
  242. bookmark.0 = j
  243. 'GLOBALV SELECT GOPHER PUTP BOOKMARK.0'
  244.  
  245. Return
  246.  
  247.